extends RigidBody2D


var thrust = Vector2(0, -980*2)
var torque = 20000

# 刚体不要使用process和physics_process函数
func _integrate_forces(state):
	if Input.is_action_pressed("ui_up"):
		# 向头顶方向施加力
		state.apply_force(thrust.rotated(rotation))
	else:
		state.apply_force(Vector2())
		
	# 控制旋转
	var rotation_direction = 0
	if Input.is_action_pressed("ui_right"):
		rotation_direction += 1
	if Input.is_action_pressed("ui_left"):
		rotation_direction -= 1
	state.apply_torque(rotation_direction * torque)
